<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<script type="text/javascript">

	//获取当前页面的路径并由?切割接收0下标的精准路径
	var url = window.location.href.split("?")[0];

	url = url.substring(url.lastIndexOf("/",url.lastIndexOf("/")-1)+1);
	//切换页码链接
	function goToUrl(pageNum) {
		//判断如果当前页面是User用户页面进入
		if (url == "user/show" || url == "/UserAddServlet" || url == "/BillModifyServlet" || url == "/UserListServlet#") {
			var fromAction = "user/show?pageNum="+pageNum; //在提交的路径后面问号传当前点击的页号
			//切换页号是保留条件
			document.getElementsByTagName("form")[0].action = fromAction; //将from表单的action加上问号传的值
			document.getElementsByTagName("form")[0].submit(); //提交from表单
		}if (url == "provider/show" || url == "/UserAddServlet" || url == "/BillModifyServlet" || url == "/UserListServlet#") {
			var fromAction = "provider/show?pageNum="+pageNum; //在提交的路径后面问号传当前点击的页号
			//切换页号是保留条件
			document.getElementsByTagName("form")[0].action = fromAction; //将from表单的action加上问号传的值
			document.getElementsByTagName("form")[0].submit(); //提交from表单
		}if (url == "bill/show" || url == "/UserAddServlet" || url == "/BillModifyServlet" || url == "/UserListServlet#") {
			var fromAction = "bill/show?pageNum="+pageNum; //在提交的路径后面问号传当前点击的页号
			//切换页号是保留条件
			document.getElementsByTagName("form")[0].action = fromAction; //将from表单的action加上问号传的值
			document.getElementsByTagName("form")[0].submit(); //提交from表单
		}
	}
	//表单输入链接
	function goToUrl1(){
		pageNum = $("#inputPage").val(); //获取表单输入的值
		if (url == "user/show" || url == "/UserAddServlet" || url == "/UserModifyServlet") {
			var fromAction ="user/show?pageNum="+pageNum;
			document.getElementsByTagName("form")[0].action = fromAction;
			document.getElementsByTagName("form")[0].submit();
		}
		if (url == "bill/show" || url == "/BillAddServlet" || url == "/BillModifyServlet") {
			var fromAction ="bill/show?pageNum="+pageNum;
			document.getElementsByTagName("form")[0].action = fromAction;
			document.getElementsByTagName("form")[0].submit();
		}
		if (url == "provider/show" || url == "/ProviderAddServlet" || url == "/ProviderModifyServlet") {
			var fromAction ="provider/show?pageNum="+pageNum;
			document.getElementsByTagName("form")[0].action = fromAction;
			document.getElementsByTagName("form")[0].submit();
		}
	}
</script>

 		<div class="page-bar">
			<ul class="page-num-ul clearfix">
				<li>共${requestScope.pageInfo.total }条记录&nbsp;&nbsp; ${requestScope.pageInfo.pageNum }/${requestScope.pageInfo.pages }页</li>
				<c:if test="${requestScope.pageInfo.pageNum > 1}">
					<a href="javascript:goToUrl(1);">首页</a>
					<a href="javascript:goToUrl(${requestScope.pageInfo.pageNum-1});">上一页</a>
				</c:if>
				<c:if test="${requestScope.pageInfo.pageNum < requestScope.pageInfo.pages }">
					<a href="javascript:goToUrl(${requestScope.pageInfo.pageNum+1 });">下一页</a>
					<a href="javascript:goToUrl(${requestScope.pageInfo.pages });">最后一页</a>
				</c:if>
				&nbsp;&nbsp;
			</ul>
		 <span class="page-go-form"><label>跳转至</label>
	     <input type="text" name="inputPage" id="inputPage" class="page-key" />页
	     <button type="button" class="page-btn" onClick="goToUrl1()">GO</button>
		</span>
		</div> 
</body>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/rollpage.js"></script>
</html>